<?php

namespace App\Nova;

use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Image;
use Laravel\Nova\Fields\Tag;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;

class Actor extends Resource
{
    public static string $model = \App\Models\Actor::class;

    public static $title = 'title';

    public static $search = [
        'title', 'abbr',
    ];

    public static function label(): string
    {
        return '演员';
    }

    public function fields(NovaRequest $request): array
    {
        return [
            ID::make()->sortable(),

            Text::make('标题', 'title')->rules('required'),
            Text::make('索引', 'abbr')->onlyOnDetail(),

            Image::make('缩略图', 'picture')->rounded()->prunable()->creationRules('required'),

            Boolean::make('显示', 'show')->default(true),

            Tag::make('视频', 'videos', Video::class)->displayAsList(),

            DateTime::make('生成时间', 'created_at')->exceptOnForms(),
            DateTime::make('更新时间', 'updated_at')->exceptOnForms(),
        ];
    }
}
